#pragma once
#pragma comment (lib, "d3d9.lib")
#pragma comment (lib, "d3dx9.lib")

#include <windows.h>
#include <windowsx.h>
#include <atlbase.h>
#include <d3d9.h>
#include <d3dx9.h>
#include <list>

#include "..\myAH\myAllocHierarchy.h"
               
using namespace std;


class myD3D {
	// pointer to directX
	LPDIRECT3D9 d3d;
	// pointer to directX Device
	LPDIRECT3DDEVICE9 d3ddev;
	// initial parameters of directX Device
	D3DPRESENT_PARAMETERS d3dpp;
	// pointer to a directX window
	HWND hWnd;

	UINT rootFramesCount;
	LPD3DXFRAME *rootFrames;
    LPD3DXANIMATIONCONTROLLER ani;

	// draw frame
	void drawFrame(LPD3DXFRAME frame);

public:
	myD3D();
	~myD3D();

	// TEMP get directX device
	LPDIRECT3DDEVICE9 getDev() { return d3ddev; }

	// a MUST finction to create directX instance
	bool Init(HWND _hWnd, bool fullscreen, int w, int h);
	// set LookAt
	bool setLookAt();
	bool setLookAt(D3DXVECTOR3 *camPosition, D3DXVECTOR3 *lookAtPosition, D3DXVECTOR3 *upDirection);
	bool setLookAt(D3DXMATRIX *view);
	// set view perspective
	bool setPerspective();
	bool setPerspective(float fovRadian, float aspect_WOverH, float z_near, float z_far);
	bool setPerspective(D3DXMATRIX *projectionMatrix);
	//setup light in the scene
	void setLight(DWORD index, bool makeOn, D3DLIGHT9 *light);
	// turn on/off 3d lighting
	void light3d(bool on);
	// change renderer state do custom one
	bool setRendState(D3DRENDERSTATETYPE state, DWORD value);

	// load SkinnedMesh
	HRESULT loadSkin(LPCWSTR path);
	
	// function to render frame
	void RenderFrame();
};